﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	论坛回复帖子页面
'	2011.11.2

Sub main
	' 回帖配置
	If Not ifNum(numReplyMin) Then numReplyMin="0"'回帖最少字数
	If Not ifNum(numReplyMax) Then numReplyMax="200"'回帖最多字数

	Dim id,text,userid,rs,a,sql,pid,author,body_
	a=getN("a",0)
	id=getN("id", 1)
	userid=user_array(0)
	checkUserStatus()'检测用户是否在服刑
	text = getD("text", "")
	pid=getN("pid",1)
	hu.title = "回复帖子"
	body_ = ""
	Select Case a
	Case 0:'保存回帖
		checkLogin()'验证登录
		If len(text)<numReplyMin*1 Then rupt "错误", "为提高回帖质量,字数必须大于"&numReplyMin
		Set rs= hu.conn("select top 1 id from 74hu_topic where id="&id)
		If Not rs.eof Then
			Dim timeInterval'防止刷帖,10秒回复一条;回帖间隔超过30s,加金币积分经验
			Set rs=hu.conn("select top 1 savetime from 74hu_reply where userid="&userid&" order by id desc")
			If Not rs.eof Then
				timeInterval = DateDiff("s", rs("savetime"), time_now)
				If timeInterval <10 Then rupt "错误", "为提高回帖质量,两次回帖间隔必须大于10秒!"
				If timeInterval >30 Then Call setUserAmount(userid, amtReply)'加金币积分经验
			End If
			hu.conn("insert into 74hu_reply (content,userid,postid,savetime)values('"&text&"',"&user_array(0)&","&id&",'"&time_now&"')")
			hu.conn("update 74hu_topic set reply=reply+1,livetime='"&time_now&"' where id="&id)
			hu.conn("update 74hu_user set reply=reply+1 where id="&user_array(0))
			body_ = body_ & "发表成功！<br/>"&hu.url("bbs_replys.asp?id="&id,"查看回复")&"<br/>"& hu.url("bbs_posts.asp?id="&id,"返回帖子")&"<br/>"
		Else
			body_ = body_ & "没有这个帖子！<br/>"
		End If
		rs.close
		Set rs=Nothing
	Case 1:'修改回帖
		checkLogin()'验证登录
		sql="select r.content from (74hu_reply r left join 74hu_topic t on (t.id=r.postid)) left join 74hu_bbs c on "&_
			"(c.classid=t.classid) where c.host="&userid&" and r.id="&id
		Set rs=hu.conn(sql)
		If Not rs.eof Then
			Dim formarray(2)
			formarray(0) = http_path&"bbs_reply.asp?id="&id&"&amp;a=11&amp;pid="&pid&"||post||修改"
			formarray(1) = "input||text$$"&nowml(rs("content"))&"$$20$$"&numReplyMax&"||<br/>"
			formarray(2) = "hidden||"&bbsSid&"$$"&sid&"||"
			body_ = body_ &  "回帖修改:<br/>" & hu.getForm(formarray) &"<br/>"
		Else
			body_ = body_ & "没有这个回帖！<br/>" &hu.url("bbs_posts.asp?id="&pid,"返回帖子")&"<br/>"
		End If
		rs.close
		Set rs=Nothing
	Case 11:'修改回帖
		checkLogin()'验证登录
		If text="" Then rupt "错误", "内容不能为空！"
		sql="update (74hu_reply r inner join 74hu_topic t on (r.postid=t.id)) inner join 74hu_bbs c on(c.classid=t.classid) "&_
			"set r.content='"&text&"' where r.id="&id&" and c.host="&userid
		hu.conn(sql)
		body_ = body_ & "修改成功！"&hu.url("bbs_posts.asp?id="&pid,"返回帖子")&"<br/>"
	Case 2:'删除回帖
		checkLogin()'验证登录
		body_ = body_ & "确定删除回帖？<br/>"&hu.url("bbs_reply.asp?id="&id&"&amp;a=12&amp;pid="&pid,"删除回帖")&" "&hu.url("bbs_posts.asp?id="&pid,"返回帖子")&"<br/>"
	Case 12:'删除回帖
		checkLogin()'验证登录
		sql="select r.* from (74hu_reply r inner join 74hu_topic t on (r.postid=t.id)) inner join 74hu_bbs c on(c.classid=t.classid) "&_
			"where r.id="&id&" and c.host="&userid
		Set rs=hu.conn(sql)
		If Not rs.eof Then
			author=rs("userid")
			hu.conn("delete from 74hu_reply where id="&id)
			hu.conn("update 74hu_user set reply=reply-1 where id="&author)'回帖数减1
			hu.conn("update 74hu_topic set reply=reply-1 where id="&pid)'回帖数减1
			body_ = body_ & "删除成功！"
		Else
			body_ = body_ & "回帖不存在或已删除！"
		End If
		body_ = body_ & hu.url("bbs_posts.asp?id="&pid,"返回帖子")&"<br/>"
		Set rs=Nothing
	Case -1:'UBB说明
		body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-UBB说明[/div]"&_
				"\wx 微笑"&showImg("face/wx")&" \sx 傻笑"&showImg("face/sx")&"<br/>"&_
				"\kl 可怜"&showImg("face/kl")&" \ot 呕吐"&showImg("face/ot")&"<br/>"&_
				"\bb 拜拜"&showImg("face/bb")&" \ll 流泪"&showImg("face/ll")&"<br/>"&_
				"\qq 亲亲"&showImg("face/qq")&" \wy 我晕"&showImg("face/wy")&"<br/>"&_
				"\yw 疑问"&showImg("face/yw")&" \bs 鄙视"&showImg("face/bs")&"<br/>"&_
				"\kb 抠鼻"&showImg("face/kb")&" \sj 睡觉"&showImg("face/sj")&"<br/>"&_
				"\mk 命苦"&showImg("face/mk")&" \lh 流汗"&showImg("face/lh")&"<br/>"&_
				"\jy 惊讶"&showImg("face/jy")&" \fn 愤怒"&showImg("face/fn")&""
	End Select
	hu.body = comUbb(body_)
End Sub

%>